package com.situ;

import javax.security.auth.kerberos.KerberosKey;

import org.junit.Test;

public class xunhuan {
	@Test//数字结构
	public void test(){
		for (int i = 1; i <= 5; i++) {
			for (int j = 1; j <=i; j++) {
				System.out.print(j);
			}
			System.out.println();
		}
	}
	@Test//正三角
	public void test2(){
		for (int a = 0; a <= 5; a++) {         //0-5
			for (int b = 5; b >= a; b--) {
				System.out.print(" ");
		}
			for (int i = 1; i <= a * 2 + 1; i++) {
				System.out.print("*");
			}
			System.out.println();
		}
	}
	@Test//倒三角
	public void test3(){
		for (int i = 0; i <= 5; i++) {
			for(int j = 0; j <= i-1; j++){
				System.out.print(" ");
			}
			for (int a = 1; a <= 11 - (i * 2); a++) {
				System.out.print("*");
			}
			System.out.println();
			
		}
	}
	@Test//偶数/奇数和
	public void test4(){
		int sum = 0;//偶数
		int sum2 = 0;//奇数
		for (int i = 0; i <= 100; i++) {//偶数
			if (i % 2 == 0) {
				//System.out.println(i);
				sum = sum + i;	
			}else if (i % 2 != 0) {			
				sum2 = sum2 + i;
			}
			}
			System.out.println("偶数和：" + sum);
			System.out.println("奇数和：" + sum2);
		}
	@Test//5的倍数，三行输出
	public void test5(){
		for (int i = 1; i <= 1000; i++) {
			if(i % 5 == 0){
				System.out.print(i + "\t");	
			}
			if(i % 15 ==0){                 //每三个都是15的倍数
				System.out.println();
			}
		}
	}
	@Test//9的阶乘
	public void test6(){
		int ji = 1;
		for (int i = 1;i <= 9;i++){
			//System.out.println(i);
			ji = ji * i;
		}
		System.out.println(ji);
		
	}
	@Test
	public void tset7(){
		for(int i = 100;i <= 200;i++){
			boolean issushu = true;
//			System.out.println(i);
			for(int j = 2;j < i;j++){
				if (i % j == 0) {//不是素数
					issushu = false;
					break;
				}
			}
			if(issushu == true){
				System.out.println(i+"素数");
			}
		}
		
	}
	
}